<admintpl file="header" />
<style type="text/css">
	.error_info{
		font-size : 13px;
		color     : red;
	}
	.sucess_info{
		font-size: 13px;
		color    : green;
	}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('Finance/finance_list')}">账单列表</a></li>
			<!-- <li class="active"><a href="{:U('Finance/recharge_log')}">充值记录</a></li>
			<li><a href="{:U('Finance/recharge')}">账户充值</a></li> -->
		</ul>
        <form class="well form-search" method="post" action="{:U('Finance/finance_list')}">
            手机号:
            <input type="text" name="customer_mobile" style="width: 100px;" value="{$customer_mobile}" placeholder="用户手机号">
            时间：
            <input id="user_date" type="month" name="user_date" value="{$user_date}"/>

            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:U('customer/index')}">清空</a>
            <a class="btn btn-success" id="create-finance">生成</a>&nbsp;<span id="info"></span>
        </form>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th width="50">ID</th>
					<th>客户手机号</th>
					<th>客户姓名</th>
					<th>所有赛事(授权码)</th>
					<th>使用总天数</th>
					<th>使用总台数</th>
					<th>总计金额</th>
					<th>详情</th>
				</tr>
			</thead>
			<tbody>
		
				<foreach name="list" item="vo">
				<tr>
					<td>{$vo.id}</td>
					<td>{$vo.customer_mobile}</td>
					<td>{$vo.customer_name}</td>
					<td>{:unSerializeEventInfo($vo['event_list'])}</td>
				    <td>{$vo.sum_use_date}</td>
				    <td>{$vo.sum_use_number}</td>
				    <td></td>
				    <td><a href="{:U('Finance/finance_info',array('mobile'=>$vo['customer_mobile'],'id'=>$vo['id']))}">详情</a></td>
				</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">
	    //时间控件初始化
	    var now      = new Date();
	    var nowYear  = now.getFullYear() ; //年
	    var nowMonth = now.getMonth()+1<10?"0"+(now.getMonth()+1):now.getMonth(); //月
	    
	    if($("#user_date").val() ==''){
	    	$("#user_date").val(nowYear+'-'+nowMonth);
	    }
        
        $(function(){
        	$("#create-finance").click(function(){

        		var user_date     = $("#user_date").val();
        		var url           = "{:U('Finance/createFinance')}";

        		var user_date_arr = new Array(); //定义一数组 
                    user_date_arr = user_date.split("-"); //字符分割 

               

                $.ajaxSetup({   
                    async : false  
                }); 


        		$.post(url,{year:user_date_arr[0],month:user_date_arr[1]},function(data){
                    if(data.status == '1'){
                        $("#info").text(data.info);
                        $("#info").addClass('sucess_info');
                        window.location.href = data.url;
                    }else if(data.status == '2'){
                    	$("#info").text(data.info);
                        $("#info").addClass('error_info');
                    }else{
                    	$("#info").text('生成失败！');
                    	$("#info").addClass('error_info');
                    }
        		})
        		
        	})
        })

	</script>
</body>
</html>